package com.mengxuegu.security;

import com.mengxuegu.web.entities.SysUser;
import com.mengxuegu.web.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 通过手机号获取用户信息和权限资源
 * @author william
 * @create 2021-07-07 23:06
 **/
@Component("mobileUserDetailsService")
public class MobileUserDetailsService extends AbstractUserDetailsService  {
    Logger logger = LoggerFactory.getLogger(MobileUserDetailsService.class);

    @Autowired
    private SysUserService sysUserService;

    @Override
    public SysUser findSysUser(String mobile) {
        logger.info("请求手机号是:"+mobile);
        //1.通过手机号查询用户信息
        SysUser user = sysUserService.findByMobile(mobile);
        logger.info("查询到user是:"+user);
        return user;
    }
}
